/*
 * carChange.java
 *
 * Created on 12 novembre 2008, 10:26
 */

package GUI;

import java.text.ParseException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import kernel.Car;

/**
 *
 * @author  coco
 */
public class carChange extends javax.swing.JFrame {

    /** Creates new form carChange */
    public carChange() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        carDamageDialog = new javax.swing.JDialog();
        jScrollPane1 = new javax.swing.JScrollPane();
        DescriptionDamageField = new javax.swing.JTextArea();
        DescriptionDamageLabel = new javax.swing.JLabel();
        kundennumerDamageLabel = new javax.swing.JLabel();
        DatumDamageLabel = new javax.swing.JLabel();
        statusDamageLabel = new javax.swing.JLabel();
        kundennumerDamageField = new javax.swing.JFormattedTextField();
        DatumDamageField = new javax.swing.JFormattedTextField();
        statusDamageField = new javax.swing.JComboBox();
        SaveCarDamageDialog = new javax.swing.JButton();
        CancelCarDamageDialog = new javax.swing.JButton();
        carChangeIdLabel = new javax.swing.JLabel();
        carChangeIdInfo = new javax.swing.JLabel();
        carChangePlateLabel = new javax.swing.JLabel();
        carChangeManufacturerLabel = new javax.swing.JLabel();
        carChangeClassLabel = new javax.swing.JLabel();
        carChangeModelLabel = new javax.swing.JLabel();
        carChangePriceFactorLabel = new javax.swing.JLabel();
        carChangeModelField = new javax.swing.JTextField();
        carChangeManufacturerField = new javax.swing.JTextField();
        carChangeCarClassField = new javax.swing.JComboBox();
        carChangePlateField = new javax.swing.JTextField();
        carChangeRegisterDateLabel = new javax.swing.JLabel();
        carChangeRegisterDateInfo = new javax.swing.JLabel();
        carChangeKilometerLabel = new javax.swing.JLabel();
        carChangePlacesLabel = new javax.swing.JLabel();
        carChangeBuyDateLabel = new javax.swing.JLabel();
        carChangeFuelLabel = new javax.swing.JLabel();
        carChangeStatusLabel = new javax.swing.JLabel();
        carChangeStatusField = new javax.swing.JComboBox();
        carChangeFuelField = new javax.swing.JComboBox();
        carChangeCancel = new javax.swing.JButton();
        carChangeSave = new javax.swing.JButton();
        carChangeDamageHistorie = new javax.swing.JPanel();
        carChangeDamageTableScroll = new javax.swing.JScrollPane();
        carChangeDamageTable = new javax.swing.JTable();
        carChangeAddDamage = new javax.swing.JButton();
        carChangePrint = new javax.swing.JButton();
        carChangeBuyDateField = new javax.swing.JFormattedTextField();
        carChangePlacesField = new javax.swing.JFormattedTextField();
        carChangeKilometerField = new javax.swing.JFormattedTextField();
        carChangePriceFactorField = new javax.swing.JFormattedTextField();

        carDamageDialog.setTitle("Schadenhistorie");
        carDamageDialog.addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                carDamageDialogWindowClosing(evt);
            }
        });

        DescriptionDamageField.setColumns(20);
        DescriptionDamageField.setRows(5);
        jScrollPane1.setViewportView(DescriptionDamageField);

        DescriptionDamageLabel.setText("Beschreibung:");

        kundennumerDamageLabel.setText("Kundennummer");

        DatumDamageLabel.setText("Datum");

        statusDamageLabel.setText("Status");

        kundennumerDamageField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0"))));

        try {
            DatumDamageField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##.##.####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        statusDamageField.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4" }));

        SaveCarDamageDialog.setText("Speichern");
        SaveCarDamageDialog.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SaveCarDamageDialogActionPerformed(evt);
            }
        });

        CancelCarDamageDialog.setText("Abbrechen");
        CancelCarDamageDialog.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CancelCarDamageDialogActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout carDamageDialogLayout = new javax.swing.GroupLayout(carDamageDialog.getContentPane());
        carDamageDialog.getContentPane().setLayout(carDamageDialogLayout);
        carDamageDialogLayout.setHorizontalGroup(
            carDamageDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(carDamageDialogLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(carDamageDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(carDamageDialogLayout.createSequentialGroup()
                        .addGroup(carDamageDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(DescriptionDamageLabel)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE)
                            .addGroup(carDamageDialogLayout.createSequentialGroup()
                                .addGroup(carDamageDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(kundennumerDamageLabel)
                                    .addComponent(DatumDamageLabel)
                                    .addComponent(statusDamageLabel))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(carDamageDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(statusDamageField, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(DatumDamageField)
                                    .addComponent(kundennumerDamageField, javax.swing.GroupLayout.DEFAULT_SIZE, 151, Short.MAX_VALUE))))
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, carDamageDialogLayout.createSequentialGroup()
                        .addComponent(CancelCarDamageDialog)
                        .addGap(32, 32, 32)
                        .addComponent(SaveCarDamageDialog)
                        .addGap(109, 109, 109))))
        );
        carDamageDialogLayout.setVerticalGroup(
            carDamageDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(carDamageDialogLayout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addGroup(carDamageDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(kundennumerDamageLabel)
                    .addComponent(kundennumerDamageField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(carDamageDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(DatumDamageLabel)
                    .addComponent(DatumDamageField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(carDamageDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(statusDamageLabel)
                    .addComponent(statusDamageField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(DescriptionDamageLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 134, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(carDamageDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(SaveCarDamageDialog)
                    .addComponent(CancelCarDamageDialog))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        setResizable(false);

        carChangeIdLabel.setText("Fahrzeugnummer");

        carChangeIdInfo.setText("XX");

        carChangePlateLabel.setText("Kennzeichen");

        carChangeManufacturerLabel.setText("Hersteller");

        carChangeClassLabel.setText("Fahrzeugklasse");

        carChangeModelLabel.setText("Modellbezeichnung");

        carChangePriceFactorLabel.setText("Preisfaktor");

        carChangeModelField.setText("jTextField3");

        carChangeManufacturerField.setText("jTextField3");

        carChangeCarClassField.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Economy", "Mittelklasse", "Oberklasse", "Luxusklasse" }));

        carChangePlateField.setText("jTextField3");

        carChangeRegisterDateLabel.setText("Aufnahmedatum");

        carChangeRegisterDateInfo.setText("XX-XX-XX");

        carChangeKilometerLabel.setText("Kilometerstand");

        carChangePlacesLabel.setText("Sitzplätze");

        carChangeBuyDateLabel.setText("Erstzulassung");

        carChangeFuelLabel.setText("Kraftstofftyp");

        carChangeStatusLabel.setText("Verleihstatus");

        carChangeStatusField.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Verfügbar", "Verleihen", "Reparatur", "Nicht Verleihbar" }));

        carChangeFuelField.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Normalbenzin", "Super", "SuperPlus", "Diesel" }));
        carChangeFuelField.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                carChangeFuelFieldActionPerformed(evt);
            }
        });

        carChangeCancel.setText("Abbrechen");
        carChangeCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                carChangeCancelActionPerformed(evt);
            }
        });

        carChangeSave.setText("Speichern");
        carChangeSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                carChangeSaveActionPerformed(evt);
            }
        });

        carChangeDamageHistorie.setBorder(javax.swing.BorderFactory.createTitledBorder("Schadenshistorie"));

        carChangeDamageTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        carChangeDamageTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                carChangeDamageTableMouseClicked(evt);
            }
        });
        carChangeDamageTableScroll.setViewportView(carChangeDamageTable);

        carChangeAddDamage.setText("Hinzufügen");
        carChangeAddDamage.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                carChangeAddDamageActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout carChangeDamageHistorieLayout = new javax.swing.GroupLayout(carChangeDamageHistorie);
        carChangeDamageHistorie.setLayout(carChangeDamageHistorieLayout);
        carChangeDamageHistorieLayout.setHorizontalGroup(
            carChangeDamageHistorieLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, carChangeDamageHistorieLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(carChangeAddDamage))
            .addComponent(carChangeDamageTableScroll, javax.swing.GroupLayout.DEFAULT_SIZE, 793, Short.MAX_VALUE)
        );
        carChangeDamageHistorieLayout.setVerticalGroup(
            carChangeDamageHistorieLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, carChangeDamageHistorieLayout.createSequentialGroup()
                .addComponent(carChangeDamageTableScroll, javax.swing.GroupLayout.DEFAULT_SIZE, 105, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(carChangeAddDamage))
        );

        carChangePrint.setText("Drucken");
        carChangePrint.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                carChangePrintActionPerformed(evt);
            }
        });

        try {
            carChangeBuyDateField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##.##.####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        carChangePlacesField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0"))));

        carChangeKilometerField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0"))));

        carChangePriceFactorField.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#,##0"))));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(117, 117, 117)
                        .addComponent(carChangePrint, javax.swing.GroupLayout.DEFAULT_SIZE, 173, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(carChangeCancel, javax.swing.GroupLayout.DEFAULT_SIZE, 173, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(carChangeSave, javax.swing.GroupLayout.DEFAULT_SIZE, 175, Short.MAX_VALUE)
                        .addGap(155, 155, 155))
                    .addComponent(carChangeDamageHistorie, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(15, 15, 15)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(carChangeIdLabel)
                                .addGap(18, 18, 18)
                                .addComponent(carChangeIdInfo))
                            .addGroup(layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(carChangePlateLabel)
                                    .addComponent(carChangeManufacturerLabel)
                                    .addComponent(carChangeClassLabel)
                                    .addComponent(carChangeModelLabel)
                                    .addComponent(carChangePriceFactorLabel))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(carChangePriceFactorField)
                            .addComponent(carChangeModelField)
                            .addComponent(carChangeManufacturerField)
                            .addComponent(carChangeCarClassField, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(carChangePlateField, javax.swing.GroupLayout.DEFAULT_SIZE, 161, Short.MAX_VALUE))
                        .addGap(36, 36, 36)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(carChangeRegisterDateLabel)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(carChangeRegisterDateInfo, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(carChangeKilometerLabel)
                                    .addComponent(carChangePlacesLabel)
                                    .addComponent(carChangeBuyDateLabel)
                                    .addComponent(carChangeFuelLabel)
                                    .addComponent(carChangeStatusLabel))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(carChangeBuyDateField, javax.swing.GroupLayout.DEFAULT_SIZE, 401, Short.MAX_VALUE)
                                    .addComponent(carChangeStatusField, javax.swing.GroupLayout.Alignment.TRAILING, 0, 401, Short.MAX_VALUE)
                                    .addComponent(carChangeFuelField, javax.swing.GroupLayout.Alignment.TRAILING, 0, 401, Short.MAX_VALUE)
                                    .addComponent(carChangePlacesField, javax.swing.GroupLayout.DEFAULT_SIZE, 401, Short.MAX_VALUE)
                                    .addComponent(carChangeKilometerField, javax.swing.GroupLayout.DEFAULT_SIZE, 401, Short.MAX_VALUE))))))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(3, 3, 3)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(carChangeIdLabel)
                            .addComponent(carChangeIdInfo))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(carChangePlateLabel)
                            .addComponent(carChangePlateField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(carChangeClassLabel)
                            .addComponent(carChangeCarClassField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(carChangeManufacturerLabel)
                            .addComponent(carChangeManufacturerField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(carChangeModelLabel)
                            .addComponent(carChangeModelField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(carChangePriceFactorField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(carChangePriceFactorLabel)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(124, 124, 124)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(carChangeStatusLabel)
                            .addComponent(carChangeStatusField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(carChangeRegisterDateLabel)
                            .addComponent(carChangeRegisterDateInfo))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(carChangePlacesLabel)
                            .addComponent(carChangePlacesField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(carChangeKilometerLabel)
                            .addComponent(carChangeKilometerField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(carChangeBuyDateLabel)
                            .addComponent(carChangeBuyDateField, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(carChangeFuelLabel)
                            .addComponent(carChangeFuelField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(carChangeDamageHistorie, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(carChangePrint)
                    .addComponent(carChangeCancel)
                    .addComponent(carChangeSave))
                .addContainerGap(44, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void carChangeCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_carChangeCancelActionPerformed
//this.setEnabled(true);
this.setVisible(false);
}//GEN-LAST:event_carChangeCancelActionPerformed

private void carChangeSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_carChangeSaveActionPerformed
   if(addupdate==1){
    if(carChangeBuyDateField.getText().equals("  .  .    ")){carChangeBuyDateField.setText("01.01.0001");}
    if(carChangePlacesField.getText().equals("")){carChangePlacesField.setText("0");}
    if(carChangeKilometerField.getText().equals("")){carChangeKilometerField.setText("0");}
    if(carChangePriceFactorField.getText().equals("")){carChangePriceFactorField.setText("0");}
    if ( carChangePlateField.getText().equals("") ){
     JOptionPane.showMessageDialog(null, "Sie müssen das Kennzeichen angeben","ERROR",JOptionPane.ERROR_MESSAGE) ;
}

else{
 String zuruck = null;// TODO add your handling code here:
                try {
                    zuruck = Car.newCar(GUI.LoginWindow.sessionID, carChangePlateField.getText(), carChangeCarClassField.getSelectedItem().toString(), carChangeManufacturerField.getText(), carChangeModelField.getText(), carChangePlacesField.getText(), carChangeKilometerField.getText(), carChangeBuyDateField.getText(), carChangeFuelField.getSelectedItem().toString(), kernel.Car.statusToNumber(carChangeStatusField.getSelectedItem().toString()), carChangePriceFactorField.getText());
                } catch (ParseException ex) {
                    Logger.getLogger(carChange.class.getName()).log(Level.SEVERE, null, ex);
                }
 if(zuruck.equals("1")){     JOptionPane.showMessageDialog(null, "Sie wurden ausgeloggt!Bitte versuchen Sie sich wieder einzuloggen","ERROR",JOptionPane.ERROR_MESSAGE) ;}
 if(zuruck.equals("4")){     JOptionPane.showMessageDialog(null, "Das Fahrzeug existiert bereits","ERROR",JOptionPane.ERROR_MESSAGE) ;}
 else{
                JOptionPane.showMessageDialog(null, "Ihr Fahrzeug wurde hinzugefügt","Neues Fahrzeug",JOptionPane.INFORMATION_MESSAGE) ;
                this.setEnabled(true);
                this.dispose();
                         String données[][] = null;
                try {
                    données = kernel.Car.searchcar(GUI.LoginWindow.sessionID, "3");
                } catch (ParseException ex) {
                    Logger.getLogger(carChange.class.getName()).log(Level.SEVERE, null, ex);
                }

        //on affiche la jTable des utilisateurs'
        String[] nomsColonne={"ID","Klasse","Hersteller","Modell","Kennzeichen","Status","Sitzplätze","Kilometerstand","Erstzulassung","Kraftstofftyp","Preis"};
        CustomEditableCellTableModel jTable2 =new CustomEditableCellTableModel(données,nomsColonne) ;
        GUI.carTab.carTable.setModel(jTable2);
        GUI.carTab.carTable=GUI.carTab.centrerTable(GUI.carTab.carTable);
       GUI.carTab.carTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
       GUI.carTab.carTable.setAutoCreateRowSorter(true);
 }
}
   }
   if(addupdate==2){
        if(carChangeBuyDateField.getText().equals("  .  .    ")){carChangeBuyDateField.setText("01.01.0001");}
    if(carChangePlacesField.getText().equals("")){carChangePlacesField.setText("0");}
    if(carChangeKilometerField.getText().equals("")){carChangeKilometerField.setText("0");}
    if(carChangePriceFactorField.getText().equals("")){carChangePriceFactorField.setText("0");}
    if ( carChangePlateField.getText().equals("") ){
     JOptionPane.showMessageDialog(null, "Sie müssen das Kennzeichen angeben","ERROR",JOptionPane.ERROR_MESSAGE) ;
}

else{
 String zuruck = null;// TODO add your handling code here:
                try {
                    zuruck = Car.updateCar(GUI.LoginWindow.sessionID, carChangeIdInfo.getText(), carChangePlateField.getText(), carChangeCarClassField.getSelectedItem().toString(), carChangeManufacturerField.getText(), carChangeModelField.getText(), carChangePlacesField.getText(), carChangeKilometerField.getText(), carChangeBuyDateField.getText(), carChangeRegisterDateInfo.getText(), carChangeFuelField.getSelectedItem().toString(), kernel.Car.statusToNumber(carChangeStatusField.getSelectedItem().toString()), carChangePriceFactorField.getText());
                } catch (ParseException ex) {
                    Logger.getLogger(carChange.class.getName()).log(Level.SEVERE, null, ex);
                }
if(zuruck!=null){
 if(zuruck.equals("1")){     JOptionPane.showMessageDialog(null, "Sie wurden ausgeloggt!Bitte versuchen Sie sich wieder einzuloggen","ERROR",JOptionPane.ERROR_MESSAGE) ;}
}
 else{
                JOptionPane.showMessageDialog(null, "Ihr Fahrzeug wurde modifiert","Modifiert Fahrzeug",JOptionPane.INFORMATION_MESSAGE) ;
                this.setEnabled(true);
                this.dispose();
 }
         String données[][] = null;
                try {
                    données = kernel.Car.searchcar(GUI.LoginWindow.sessionID, "3");
                } catch (ParseException ex) {
                    Logger.getLogger(carChange.class.getName()).log(Level.SEVERE, null, ex);
                }

        //on affiche la jTable des utilisateurs'
        String[] nomsColonne={"ID","Klasse","Hersteller","Modell","Kennzeichen","Status","Sitzplätze","Kilometerstand","Erstzulassung","Kraftstofftyp","Preis"};
        CustomEditableCellTableModel jTable2 =new CustomEditableCellTableModel(données,nomsColonne) ;
        GUI.carTab.carTable.setModel(jTable2);
        GUI.carTab.carTable=GUI.carTab.centrerTable(GUI.carTab.carTable);
       GUI.carTab.carTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
       GUI.carTab.carTable.setAutoCreateRowSorter(true);
}
   }
}//GEN-LAST:event_carChangeSaveActionPerformed

private void carChangeDamageTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_carChangeDamageTableMouseClicked

}//GEN-LAST:event_carChangeDamageTableMouseClicked

private void carChangeAddDamageActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_carChangeAddDamageActionPerformed

this.setEnabled(false);
carDamageDialog.setSize(400,337);
carDamageDialog.setTitle("Hinzufügen eine Schade");
carDamageDialog.setLocationRelativeTo(null);
carDamageDialog.setVisible(true);
}//GEN-LAST:event_carChangeAddDamageActionPerformed

private void carChangePrintActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_carChangePrintActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_carChangePrintActionPerformed

private void carDamageDialogWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_carDamageDialogWindowClosing
    carDamageDialog.setVisible(false);
    this.setEnabled(true);

}//GEN-LAST:event_carDamageDialogWindowClosing

private void CancelCarDamageDialogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CancelCarDamageDialogActionPerformed
    carDamageDialog.setVisible(false);
    this.setEnabled(true);
}//GEN-LAST:event_CancelCarDamageDialogActionPerformed

private void SaveCarDamageDialogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SaveCarDamageDialogActionPerformed
    if(DatumDamageField.getText().equals("  .  .    ")){DatumDamageField.setText("01.01.0001");}
    if ( kundennumerDamageField.getText().equals("") ){
     JOptionPane.showMessageDialog(null, "Sie müssen das kundennumer angeben","ERROR",JOptionPane.ERROR_MESSAGE) ;
}

else{
 String zuruck = null;// TODO add your handling code here:
            try {
                // TODO add your handling code here:
                zuruck = Car.newDamage(GUI.LoginWindow.sessionID, carChangeIdInfo.getText(), kundennumerDamageField.getText(), DatumDamageField.getText(), statusDamageField.getSelectedItem().toString(), DescriptionDamageField.getText());
            } catch (ParseException ex) {
                Logger.getLogger(carChange.class.getName()).log(Level.SEVERE, null, ex);
            }
                JOptionPane.showMessageDialog(null, "Ihr Schade wurde hinzugefügt","Neue Schade",JOptionPane.INFORMATION_MESSAGE) ;
                 String data[][] = null;
            try {
                data = kernel.Car.searchdamage(GUI.LoginWindow.sessionID, carChangeIdInfo.getText());
            } catch (ParseException ex) {
                Logger.getLogger(carChange.class.getName()).log(Level.SEVERE, null, ex);
            }

        //on affiche la jTable des utilisateurs'
        String[] nomsColonne={"ID","Kundenid","Datum","Beschreibung","Status","Ersteller"};
        CustomEditableCellTableModel jTable2 =new CustomEditableCellTableModel(data,nomsColonne) ;
        carChangeDamageTable.setModel(jTable2);
        carChangeDamageTable=GUI.carTab.centrerTable(carChangeDamageTable);
        carChangeDamageTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
        carChangeDamageTable.setAutoCreateRowSorter(true);
        carDamageDialog.setVisible(false);
        this.setEnabled(true);
}
}//GEN-LAST:event_SaveCarDamageDialogActionPerformed

private void carChangeFuelFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_carChangeFuelFieldActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_carChangeFuelFieldActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new carChange().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton CancelCarDamageDialog;
    public javax.swing.JFormattedTextField DatumDamageField;
    private javax.swing.JLabel DatumDamageLabel;
    public javax.swing.JTextArea DescriptionDamageField;
    private javax.swing.JLabel DescriptionDamageLabel;
    private javax.swing.JButton SaveCarDamageDialog;
    public static javax.swing.JButton carChangeAddDamage;
    public javax.swing.JFormattedTextField carChangeBuyDateField;
    private javax.swing.JLabel carChangeBuyDateLabel;
    private javax.swing.JButton carChangeCancel;
    public javax.swing.JComboBox carChangeCarClassField;
    private javax.swing.JLabel carChangeClassLabel;
    private javax.swing.JPanel carChangeDamageHistorie;
    public static javax.swing.JTable carChangeDamageTable;
    private javax.swing.JScrollPane carChangeDamageTableScroll;
    public javax.swing.JComboBox carChangeFuelField;
    private javax.swing.JLabel carChangeFuelLabel;
    public javax.swing.JLabel carChangeIdInfo;
    public javax.swing.JLabel carChangeIdLabel;
    public javax.swing.JFormattedTextField carChangeKilometerField;
    private javax.swing.JLabel carChangeKilometerLabel;
    public javax.swing.JTextField carChangeManufacturerField;
    private javax.swing.JLabel carChangeManufacturerLabel;
    public javax.swing.JTextField carChangeModelField;
    private javax.swing.JLabel carChangeModelLabel;
    public javax.swing.JFormattedTextField carChangePlacesField;
    private javax.swing.JLabel carChangePlacesLabel;
    public javax.swing.JTextField carChangePlateField;
    private javax.swing.JLabel carChangePlateLabel;
    public javax.swing.JFormattedTextField carChangePriceFactorField;
    private javax.swing.JLabel carChangePriceFactorLabel;
    private javax.swing.JButton carChangePrint;
    public javax.swing.JLabel carChangeRegisterDateInfo;
    private javax.swing.JLabel carChangeRegisterDateLabel;
    private javax.swing.JButton carChangeSave;
    public javax.swing.JComboBox carChangeStatusField;
    private javax.swing.JLabel carChangeStatusLabel;
    private javax.swing.JDialog carDamageDialog;
    private javax.swing.JScrollPane jScrollPane1;
    public javax.swing.JFormattedTextField kundennumerDamageField;
    private javax.swing.JLabel kundennumerDamageLabel;
    public javax.swing.JComboBox statusDamageField;
    private javax.swing.JLabel statusDamageLabel;
    // End of variables declaration//GEN-END:variables
public static int addupdate;
}
